<%--
  Created by IntelliJ IDEA.
  User: YYY-Work
  Date: 2017/5/16
  Time: 17:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<html>
<head>
    <title>订单详情</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>


    <!-- start分页需要使用以下三个js -->
    <script type="text/javascript" src="<%=basePath%>/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/admin/utils.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/base/listtable.js"></script>

    <style>
        .table th, .table td {
            text-align: center;
            vertical-align: middle!important;
        }

        .chat-discussion{
            background: #eee;
            padding: 15px;
            height: 400px;
            overflow-y: auto;
        }

        .chat-message
        {
            padding: 10px 20px;
        }

        .message-avatar {
            height: 48px;
            width: 48px;
            border: 1px solid #e7eaec;
            border-radius: 4px;
            margin-top: 1px;
        }

        .chat-discussion .chat-message.left .message-avatar {
            float: left;
            margin-right: 10px;
        }
        .chat-discussion .chat-message.right .message-avatar {
            float: right;
            margin-left: 10px;
        }

        .message {
            background-color: #fff;
            border: 1px solid #e7eaec;
            text-align: left;
            display: block;
            padding: 10px 20px;
            position: relative;
            border-radius: 4px;
        }

        .chat-discussion .chat-message.left .message {
            text-align: left;
            margin-left: 55px;
        }
        .chat-discussion .chat-message.right .message {
            text-align: right;
            margin-right: 55px;
        }

        .message-author
        {
            font-size: 13px;
            color: #337ab7;
            text-decoration: none;
            background-color: transparent;
        }

        .message-date {
            font-size: 10px;
            color: #888888;
        }

        .chat-discussion .chat-message.left .message-date {
            float: right;
        }
        .chat-discussion .chat-message.right .message-date {
            float: left;
        }

        .message-content
        {
            display: block;
            line-height: 1.43;
        }

    </style>

</head>
<body class="skin-blue">

<!-- header logo: style can be found in header.less -->


<!-- getHeader -->
<s:action name="getHeader" namespace="/privilege" executeResult="true"/>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <!-- Left side column. contains the logo and sidebar -->

    <!-- getMenus -->
    <s:action name="getMenus" namespace="/privilege" executeResult="true"/>

    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="right-side">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <small>订单详情</small>
            </h1>

        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">

                        <div class="box box-danger">

                            <div class="box-body col-sm-4">
                                <form class="form-horizontal" enctype="multipart/form-data">

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">订单号</label>
                                            <div class="col-sm-8">
                                                <label class="form-control" id="registerid">${registerOrder.registerid}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">下单时间</label>
                                            <div class="col-sm-8">
                                                <label class="form-control"><fmt:formatDate value="${registerOrder.createDate}" type="both"/></label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">订单类型</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.registerTypeName}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">用户 <input type="text" id="UserId" style="display: none;" name="UserId" value="${registerOrder.userid}"></label>
                                            <div class="col-sm-8">
                                            	
                                                <label class="form-control">${registerOrder.userName}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">就诊人</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${not empty registerOrder.patientName ? registerOrder.patientName : ''}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">接诊医生</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.accepterName}</label>
                                            </div>
                                        </div>

                                        <div class="form-group" id="department">
                                            <label class="col-sm-4 control-label">科室</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.departmentName}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">医院</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.entityName}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">收费类型</label>
                                            <div class="col-sm-8">
                                                <label class="form-control" id="orderfeetypeid"/>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">支付方式</label>
                                            <div class="col-sm-8">
                                                <label class="form-control" id="paytypeid"/>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">支付金额</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.registerTotal}</label>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">医生入账</label>
                                            <div class="col-sm-8">
                                                <label class="form-control">${registerOrder.registerPayoffTotal}</label>
                                            </div>
                                        </div>

                                        <div class="form-group" id="scheduleTime_layout">
                                            <label class="col-sm-4 control-label">预约时间</label>
                                            <div class="col-sm-8">
                                                <label class="form-control" id="scheduleTime"/>
                                            </div>
                                        </div>

                                        <div class="form-group" id="scheduleDuration_layout">
                                            <label class="col-sm-4 control-label">预约时长</label>
                                            <div class="col-sm-8">
                                                <label class="form-control" id="scheduleDuration"/>
                                            </div>
                                        </div>





                                    </fieldset>
                                </form>

                            </div><!-- /.box-body -->

                            <div class="box-body col-sm-6">
                                <form class="form-horizontal" enctype="multipart/form-data">

                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">备注</label>
                                            <div class="controls col-sm-10">
                                                <div class="textarea">
                                                    <textarea id="advertisementDesc" name="advertisementDesc" type=""
                                                              rows="3" class="form-control" style="width: 100%"
                                                              readonly></textarea>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">操作信息</label>
                                            <div class="col-sm-10">

                                                <table cellpadding="3" cellspacing="1"
                                                       class="table table-bordered table-hover" id="list-table">
                                                    <thead>
                                                    <tr>
                                                        <th>执行动作</th>
                                                        <th>执行时间</th>
                                                        <th>执行人</th>
                                                        <th>结果</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>

                                                    <s:iterator value="registerOrderActions" id="key"
                                                                var="registerOrderAction">
                                                        <tr>
                                                            <td>
                                                                    ${registerOrderAction.actionName}
                                                            </td>
                                                            <td>
                                                                <fmt:formatDate value="${registerOrderAction.actionDate}" type="both"/>
                                                            </td>
                                                            <td>
                                                                    ${registerOrderAction.operatorName}
                                                            </td>
                                                            <td>
                                                                    ${registerOrderAction.doendStatus}
                                                            </td>
                                                        </tr>
                                                    </s:iterator>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label"></label>

                                            <div class="controls col-sm-10">
                                                <button class="btn btn-success" type="button">结诊</button>

                                                <button class="btn btn-info" type="button" style="margin-left: 15px" data-toggle="modal" data-target="#myModal">
                                              	      病历
                                                </button>
                                                
                                                 <button class="btn btn-info" type="button" style="margin-left: 15px"  onclick="queryUser()">
                                              	      扣款
                                                </button>

                                                <button class="btn btn-primary" type="button" style="margin-left: 15px" onclick="queryMsg()">
                                            	        查看消息
                                                </button>

                                                <button class="btn btn-info" type="button" style="margin-left: 15px" onclick="queryMember()">
                                                  	  查看群组成员
                                                </button>

                                            </div>
                                        </div>
                                    </fieldset>
                                </form>
                            </div>
                        </div><!-- /.box -->

                    </div><!-- /.box -->


                </div>
            </div>

        </section><!-- /.content -->
    </aside><!-- /.right-side -->
</div><!-- ./wrapper -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    就诊人病历
                </h4>
            </div>
            <div class="modal-body">

                <div class="row">
                    <c:if test="${not empty medicalTreatRecord.patpage1}">
                        <img src="${medicalTreatRecord.patpage1}" class="col-sm-2 img-rounded">
                    </c:if>

                    <c:if test="${not empty medicalTreatRecord.patpage2}">
                        <img src="${medicalTreatRecord.patpage2}" class="col-sm-2 img-rounded">
                    </c:if>

                    <c:if test="${not empty medicalTreatRecord.patpage3}">
                        <img src="${medicalTreatRecord.patpage3}" class="col-sm-2 img-rounded">
                    </c:if>

                    <c:if test="${not empty medicalTreatRecord.patpage4}">
                        <img src="${medicalTreatRecord.patpage4}" class="col-sm-2 img-rounded">
                    </c:if>

                    <c:if test="${not empty medicalTreatRecord.patpage5}">
                        <img src="${medicalTreatRecord.patpage5}" class="col-sm-2 img-rounded">
                    </c:if>

                    <c:if test="${not empty medicalTreatRecord.patpage6}">
                        <img src="${medicalTreatRecord.patpage6}" class="col-sm-2 img-rounded">
                    </c:if>
                </div>


                <c:if test="${not empty medicalTreatRecord}">
                    ${medicalTreatRecord.patientDescribe}
                </c:if>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-labelledby="messageModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="messageModalLabel">
                    咨询对话消息
                </h4>
            </div>
            <div class="modal-body" id="modal-body">


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="memberModal" tabindex="-1" role="dialog" aria-labelledby="messageModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">
                    群组成员
                </h4>
            </div>
            <div class="modal-body" id="member-body">


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


<div class="modal fade" id="UserModal" tabindex="-1" role="dialog" aria-labelledby="UserModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">
                     	扣款
                </h4>
            </div>
            <div class="user-body" id="user-body">
	  <div class="form-group">
	  <label class="col-sm-3 control-label">用户余额：</label>
                                            <div class="col-sm-9">
                                                <label class="form-control" id="balance"/>
                                            </div>
                                            </div>
             <div class="form-group">
                                              <label class="col-sm-3 control-label">扣款额度：</label>
                                            <div class="col-sm-9">
                                                 <input type="text" id="time" class="input-small"  style="width: 100%" />
                                            </div>
              </div>
            <div class="modal-footer">
            
            <button type="button" class="btn btn-primary" style="margin-left: 15px"  onclick="cutPament()">确认扣款
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


</body>

<script type="text/javascript">

    var detail_orderfeetypeid = "${registerOrder.orderfeetypeid}";
    var detail_paytypeid = "${registerOrder.paytypeid}";
    var detail_registerguideid = "${registerOrder.registerguideid}";
    var detail_scheduleTime = "${not empty registerOrder.scheduleTime ? registerOrder.scheduleTime : ''}";
    var detail_scheduleDuration = "${not empty registerOrder.scheduleDuration ? registerOrder.scheduleDuration : ''}";

    $(document).ready(new function () {

        if ("1" == detail_orderfeetypeid) {
            $("#orderfeetypeid").html("收费");
        } else {
            $("#orderfeetypeid").html("免费");
        }

        if ("0" == detail_paytypeid) {
            $("#paytypeid").html("健康卡");
        } else if ("1" == detail_paytypeid) {
            $("#paytypeid").html("微信");
        } else if ("2" == detail_paytypeid) {
            $("#paytypeid").html("支付宝");
        }

        if ("3" == detail_registerguideid || "6" == detail_registerguideid) {
            $("#scheduleTime").html(detail_scheduleTime);
            $("#scheduleDuration").html(detail_scheduleDuration + "分钟");
            $("#scheduleTime_layout").show();
            $("#scheduleDuration_layout").show();
        } else {
            $("#scheduleTime_layout").hide();
            $("#scheduleDuration_layout").hide();
        }
    })

    function queryMsg() {

        var detail_registerid=$("#registerid").html();
        $.ajax({
            type: "POST",
            url: '../order/aiaxQueryOrderImMessage.action?groupid='+detail_registerid,
            cache: false,
            dataType: 'json',
            success: successfun,
        });
    }

    function queryMember() {
        var detail_registerid=$("#registerid").html();
        $.ajax({
            type: "POST",
            url: '../order/ajaxQueryOrderMember.action?registerID='+detail_registerid,
            cache: false,
            dataType: 'json',
            success: queryMemberSuccessfun,
        });
    }
    
    
     function queryUser() {
        var UserId=$("#UserId").val();
        $.ajax({
            type: "POST",
            url: '../order/ajaxQueryUser.action?UserID='+UserId,
            cache: false,
            dataType: 'json',
            success: queryUserSuccessfun,
        });
    }
    
        
     function cutPament() {
        var UserId=$("#UserId").val();
        var detail_registerid=$("#registerid").html();
          var time=$("#time").val();
        $.ajax({
            type: "POST",
            url: '../order/ajaxCutPament.action?UserID='+UserId+'&registerID='+detail_registerid
           			 +'&time='+time,
            cache: false,
            dataType: 'json',
            success: cutPamentSuccessfun,
        });
    }


    function cutPamentSuccessfun(data) {
      $("#user-body").empty();
        if (data.errorCode >= 0) {
        	
           $("#user-body").append("扣款成功!");
        }else
        {
            $("#user-body").append("扣款失败!");
        }
    }

    function queryUserSuccessfun(data) {

        if (data.errorCode>=0)
        {
           $("#balance").html(data.user.balance);
            $("#UserModal").modal();
        }else
        {
            alert(data.errorMsg);
        }

    }
    
    function successfun(data) {
        if (data.errorCode >= 0) {
            var content=data.content;
            $("#modal-body").empty();
            $("#modal-body").append(content);
            $("#messageModal").modal();
        }else
        {
            alert(data.errorMsg);
        }
    }

    function queryMemberSuccessfun(data) {

        if (data.errorCode>=0)
        {
            $("#member-body").empty();
            $("#member-body").append(data.content);
            $("#memberModal").modal();
        }else
        {
            alert(data.errorMsg);
        }

    }

</script>
</html>
